/*
reducer函数模块: 根据当前state和指定action返回一个新的state
 */
import {combineReducers} from 'redux'
import {RECEIVE_USER,SHOW_ERROR_MSG} from './action_types'
import storageUtils from '../utils/storageUtils'
 /*
管理user状态数据的reducer
 */
const initUser =  storageUtils.getUser()
 function user(state=initUser,action){
    switch (action.type) {
        case RECEIVE_USER:
           return action.user
        case SHOW_ERROR_MSG:
            return {errorMsg:action.errorMsg}
        default:
            state;
    }
 }

 /*
向外暴露合并后产生的总reducer函数
总的state的结构:
  {
    headerTitle: '',
    user: {}
  }
 */
export default combineReducers({
    user
})